package h0731;

import java.util.Scanner;

public class FindTheSubStringMeetsRequirements2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); // 单词个数
        sc.nextLine(); // 消耗换行符
        String[] words = new String[n];
        for (int i = 0; i < n; i++) {
            words[i] = sc.nextLine();
        }
        String s = sc.nextLine();
        int ans = getRes(words, s);
        System.out.println(ans);
    }

    private static int getRes(String[] words, String s) {
        int[] charCount = new int[26]; // 计数数组，用于存储 chars 中每个字母的出现频率
        int wildcardCount = 0; // 统计 '?' 的个数

        // 统计 chars 中每个字符的频率
        for (char c : s.toCharArray()) {
            if (c == '?') {
                wildcardCount++;
            } else {
                charCount[c - 'a']++;
            }
        }

        int count = 0;
        for (String word : words) {
            //wildcardCount问号出现的次数
            if (canSpell(word, charCount, wildcardCount)) {
                count++;
            }
        }
        return count;
    }

    private static boolean canSpell(String word, int[] charCount, int wildcardCount) {
        int[] wordCount = new int[26]; // 计数数组，用于存储当前单词中每个字母的出现频率

        // 统计当前单词中每个字符的频率
        for (char c : word.toCharArray()) {
            wordCount[c - 'a']++;
        }

        // 检查当前单词是否可以用 chars 中的字符拼写
        for (int i = 0; i < 26; i++) {
            if (wordCount[i] > charCount[i]) {
                int needed = wordCount[i] - charCount[i];
                if (needed <= wildcardCount) {
                    wildcardCount -= needed; // 使用万能字符补足差额
                } else {
                    return false; // 无法匹配当前字符
                }
            }
        }
        return true; // 成功匹配整个单词
    }
}
